package com.chuangjiangx.member.basic.ddd.domain.model.msg;

import com.chuangjiangx.commons.wx.msg.model.AbstractBaseData;
import com.chuangjiangx.commons.wx.msg.model.Keyword4Data;
import com.chuangjiangx.commons.wx.msg.model.MsgDataMeta;
import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author cj-ch
 * @date 2018/1/31 上午9:31
 * 积分变动提醒
 */
@Data
public class MbrScoreChangeMsg extends AbstractMbrWXMsg  {
    /**
     * 标题
     */
    private String title = "您的积分有新的变动,详情如下:";
    /**
     * 获取时间
     */
    private Date getTime;
    /**
     * 获得积分
     */
    private String score;
    /**
     * 获得原因
     */
    private String getTheReason;
    /**
     * 当前积分
     */
    private Long currentScore;
    /**
     * 备注
     */
    private String remark = "感谢您的使用";

    public MbrScoreChangeMsg(Date getTime, String score, String getTheReason, Long currentScore) {
        this.getTime = getTime;
        this.score = score;
        this.getTheReason = getTheReason;
        this.currentScore = currentScore;
    }

    @Override
    public AbstractBaseData toMsgData() {
        Keyword4Data data = new Keyword4Data();
        data.setFirst(new MsgDataMeta(title));
        //获取时间
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        data.setKeyword1(new MsgDataMeta(format.format(getTime)));
        data.setKeyword2(new MsgDataMeta(String.valueOf(score)));
        data.setKeyword3(new MsgDataMeta(getTheReason));
        data.setKeyword4(new MsgDataMeta(String.valueOf(currentScore)));
        data.setRemark(new MsgDataMeta(remark));
        return data;
    }

    @Override
    public WXMsg getWXMsg() {
        return WXMsg.MBR_SCORE_CHANGE;
    }

}
